#ifndef		_DRV_SOFT_IIC_H_
#define		_DRV_SOFT_IIC_H_

#include "drv_common.h"
#include "hc32_common.h"
#include "hc32f460_gpio.h"

#define DRV_I2C_WR                0x0000
#define DRV_I2C_RD               (1u << 0)

typedef void(*Drv_i2c_start)(uint8_t);
typedef void(*Drv_i2c_stop)(uint8_t);
typedef uint8_t(*Drv_i2c_wait_ask)(uint8_t);
typedef void(*Drv_i2c_ask)(uint8_t);
typedef void(*Drv_i2c_nask)(uint8_t);
typedef uint8_t(*Drv_i2c_read_byte)(uint8_t,uint8_t);
typedef void(*Drv_i2c_send_byte)(uint8_t,uint8_t);

typedef struct{
	uint32_t 					scl_pin;
	uint32_t 					sda_pin;
	Drv_i2c_start 				start;
	Drv_i2c_stop  				stop;
	Drv_i2c_wait_ask 			wait_ask;
	Drv_i2c_ask      			ask;
	Drv_i2c_nask     			nask;
	Drv_i2c_read_byte 			read_byte;
	Drv_i2c_send_byte 			send_byte;
}Drv_I2c_Bus;

int8_t drv_i2c_register(uint32_t scl_pin,uint32_t sda_pin,Drv_I2c_Bus *i2c_bus);
int8_t drv_i2c_destory(Drv_I2c_Bus *i2c_bus);

void drv_i2c_init(void);
#endif